(function(){
    const tdj = {
        $: ele => {
            return document.querySelectorAll(ele);
        },
        "videoPlay": function () {
            const videoNode = this.$('.videoNode')[0];
            const videoPlayNode = this.$('.videoPlayNode')[0];
            const close = this.$('.modal-close')[0];
            const modalTitle = this.$('.modalTitle')[0];

            videoPlayNode.onclick = function () {
                videoNode.src = this.getAttribute('videosrc');
                modalTitle.innerHTML = '天地劫 超绝手游';
                videoNode.play();
            };

            close.onclick = () => {
                videoNode.pause();
            }
        },
        "newVideo": function () {
            const allNewVideo = this.$('.bg-hover');
            const videoNode = this.$('.videoNode')[0];
            const modalTitle = this.$('.modalTitle')[0];

            for (let i = 0; i < allNewVideo.length; i++) {
                allNewVideo[i].onclick = function () {
                    videoNode.src = this.getAttribute('videosrc');
                    videoNode.play();
                    modalTitle.innerHTML = this.parentNode.nextElementSibling.children[1].innerHTML
                }                
            }
        }
    }

    tdj.videoPlay();
    tdj.newVideo();
})();